#!/bin/bash

PROJECT_ROOT=/go/src/erasure-service
OUTPUT_DIR=standalone
BINARY=erasure-service
ENV_IMG=erasure_env:base
SERVICE_IMG=erasure_service:latest
UGID=$(id -u):$(id -g)

docker run \
    --rm \
    -e GOPROXY=https://goproxy.cn \
    -e GO111MODULE=on \
    -e PROJECT_ROOT=$PROJECT_ROOT \
    -e OUTPUT_DIR=$OUTPUT_DIR \
    -e BINARY=$BINARY \
    -e UGID=$UGID \
    -v $(readlink -f ../..):$PROJECT_ROOT \
    -w $PROJECT_ROOT \
    $ENV_IMG
    
cd ../../$OUTPUT_DIR

docker build . -t $SERVICE_IMG
